package com.jiazixuan.stock;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.crypto.password.PasswordEncoder;

@SpringBootTest
public class testPasswordEncoder {
    @Autowired
    private PasswordEncoder passwordEncoder;

    @Test
    public void test01(){
        String pwd = "1234";
        String encode = passwordEncoder.encode(pwd);
        //$2a$10$tGRTmWAJkh5j3Rhm1gvUvuNPN6L0p61gu66eHHo4REbDEKcd7.S82
        System.out.println("encode = " + encode);
    }

    /**
     * 测试密码匹配
     */
    @Test
    public void test02(){
        String pwd = "1234";
        String enpwd = "$2a$10$tGRTmWAJkh5j3Rhm1gvUvuNPN6L0p61gu66eHHo4REbDEKcd7.S82";
        boolean isSuccess = passwordEncoder.matches(pwd, enpwd);
        System.out.println("isSuccess = " + isSuccess);
    }
}
